import time
from Base.Base import Base
from selenium.webdriver.common.by import By
# 页面类
class Page(Base):
    # 获取登录的元素定位
    login_loc = (By.XPATH, '/html/body/div[2]/div/div[1]/div/a[1]')
    # # 断言是否跳转到登录页面
    # dy1_text=(By.XPATH,'//*[@id="loginform"]/div/div/div/div/div[1]/div[1]/a[1]')
    # 点击输入账号元素定位
    username_loc=(By.NAME,'uname')
    # 点击输入密码元素定位
    password_loc=(By.ID,'password')
    # 强制等待
    # 点击登录按钮元素定位
    loginbtn_loc=(By.XPATH,'//*[@id="save"]')
    # 点击确认
    sure_loc=(By.XPATH,'//*[@id="bindSub"]')

#    封装定位方法
#         点击登录
    def login(self):
        self.click(self.login_loc)
    # # 断言文本：帐号登录
    # def dy1(self):
    #     self.get_text(self.dy1_text)

    # 输入账号
    def username(self):

     self.send_keys(self.username_loc,"18986670716")
        # self.find_element(self.driver).send_keys(username)
    # 输入密码
    def password(self):
        self.send_keys(self.password_loc, "Aa123456")
        # self.find_element(self.driver).send_keys(password)
    # 点击登录按钮
    def loginbtn(self):
        self.click(self.loginbtn_loc)
    # 点击确认按钮
    def sure(self):
        self.click(self.sure_loc)

#     业务逻辑
    def jiuxian_luoji1(self):
        self.open_url('https://www.jiuxian.com/')
        self.login()
        # print(self.dy1_text)
        # assert "帐号登录" == self.dy1_text
        self.username()
        self.password()
        # 强制等待
        time.sleep(10)
        self.loginbtn()
        self.sure()






